// api/tenderApi.ts
import api from './config';
import type {TendersGETResponse, TendersBidsGETResponse} from "../../types/api";


/**
 * 获取所有招标记录
 */
export const getAllTenders = async (): Promise<TendersGETResponse> => {
  const response = await api.get<TendersGETResponse>('/tenders/');
  return response.data;
};

/**
 * 获取指定招标下的所有投标信息
 */
export const getBidsForTender = async (tenderId: string): Promise<TendersBidsGETResponse> => {
  const response = await api.get<TendersBidsGETResponse>(`/tenders/${tenderId}/bids`);
  return response.data;
};

/**
 * 删除一个招标记录（包括其所有投标）
 */
export const deleteTenderRecord = async (tenderId: string): Promise<{ message: string }> => {
  const response = await api.delete<{ message: string }>(`/tenders/${tenderId}`);
  return response.data;
};
